using System;
using TestCases.CompareAssert.Core.Builders;
using TestCases.CompareAssert.Core.Comparers.Interfaces;
using TestCases.CompareAssert.Core.Interfaces;

namespace TestCases.CompareAssert.Core.Comparers.Stateless
{
    public class TypeComparer : IObjectComparer
    {
        public const string IdentifiableName = "TypeComparer";
        
        private static readonly TypeComparer _instance = new TypeComparer();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static TypeComparer()
// ReSharper restore EmptyConstructor
        {
        }

        private TypeComparer()
        {
        }

        public static TypeComparer Instance
        {
            get { return _instance; }
        }


        public string Name
        {
            get { return IdentifiableName; }
        }

        public IResultBuilder Compare(ICompareContext context)
        {
            Type t1 = context.LType, t2 = context.RType;
            return this.IsBoolResult(t1 == t2, context).
                ForEquals("<{LPath}> and <{RPath}> types are same [{LType} == {RType}].").
                ForNotEquals("<{LPath}> and <{RPath}> types are different [{LType} != {RType}].");
        }
    }
}